package com.itheima.exerciseTest.test01_09;

import java.util.Random;
import java.util.Scanner;

public class Test8 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        method( () -> {
            System.out.println("请输入要输出:");
            int x = sc.nextInt();
            System.out.println("请输入要输出:");
            int y = sc.nextInt();
            return r.nextInt(y - x) + x;
        } );
        method(new InterTset8() {
            @Override
            public int getRandom() {
                System.out.println("请输入要输出:");
                int x = sc.nextInt();
                System.out.println("请输入要输出:");
                int y = sc.nextInt();
                return r.nextInt(y - x) + x;
            }
        });
    }

    public static void method(InterTset8 interTset8){
            System.out.println(interTset8.getRandom());

    }
}

interface InterTset8 {
    int getRandom();
}